package com.campus.controller;

import com.campus.common.Result;
import com.campus.service.PostLikeService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class PostLikeController {
    @Autowired
    private PostLikeService postLikeService;

    /**
     * 点赞加统计点赞条数
     */
    @PostMapping("/post/{postId}/like")
    public Result likePost(@PathVariable("postId") String postId, HttpServletRequest request) {
        Result result = postLikeService.likePost(postId, request);
        return result;
    }

    /**
     * 这个是取消点赞加统计点赞条数
     */
    @PostMapping("/post/{postId}/unlike")
    public Result unLikePost(@PathVariable("postId") String postId, HttpServletRequest request) {
        Result result = postLikeService.unLikePost(postId, request);
        return result;
    }

    /**
     * 校验该用户是否给当前帖子点赞
     */
    @GetMapping("/post/{postId}/check-like")
    public Result checkLike(@PathVariable("postId") String postId, HttpServletRequest request) {
        Result result = postLikeService.checkLike(postId, request);
        return result;
    }
}
